<?php
// двиг форму 
$log_usr = $_POST['log_usr'];     // получаем логин
$pas_usr = $_POST['pas_usr'];     // получаем пароль

$i=$pas_usr;
 if ($pas_usr!="" ){

$times=$i;
$send=$i;
 if ($log_usr=="a" ){ $times=$pas_usr;    };
 if ($log_usr=="r" ){ $times=$pas_usr;   };
 if ($log_usr=="l" ){ $times=$pas_usr;  };

$send="change ".$i;

$pass="22";
$login="bt2";
$base="bt2";

$db=mysql_connect("localhost",$login,$pass); 
mysql_select_db ($base,$db);

if ($log_usr=="l" )
{  
$result=mysql_query ("SELECT prof,log FROM chat ",$db );
$myrow= mysql_fetch_array($result) ;

$send="";
while ($myrow=mysql_fetch_array($result) )
{$send.='['.$myrow["prof"]. '] : ' .$myrow["log"]. ' 
'; }

$send=iconv ("cp1251","utf-8",$send) ;

 }
 
if ( ($log_usr=="r" )|| ($log_usr=="a" )){
$result=mysql_query ("SELECT num FROM chat WHERE id=1 ",$db );
$myrow= mysql_fetch_array($result) ;
$times=$myrow["num"];
$times=$times+1;

$res=mysql_query("UPDATE chat SET num='".strtolower($times)."' WHERE id= 1 ", $db );
//$res=mysql_query("UPDATE chat SET log='".strtolower($pas_usr)."' WHERE id= 2 ", $db );
$res=mysql_query("INSERT INTO  chat  (log,num) VALUES('".strtolower($pas_usr)."','".strtolower($times)."')", $db );
//$res=mysql_query("INSERT INTO  chat  (log,num) VALUES('2s',22)", $db );
$send="change ".$times;
}

//echo $send;
 echo 'asdas';

}

?>